package com.cityfood.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cityfood.mapper.CfOrderItemMapper;
import com.cityfood.pojo.CfOrderItem;
import com.cityfood.pojo.CfOrderItemExample;
import com.cityfood.pojo.CfOrderItemExample.Criteria;
import com.cityfood.service.OrderItemService;

@Service
public class OrderItemServiceImpl implements OrderItemService {
	
	@Autowired
	private CfOrderItemMapper itemMapper;

	@Override
	public CfOrderItem selectOrderItemById(Integer id) {
		CfOrderItem orderItem = itemMapper.selectByPrimaryKey(id);
		return orderItem;
	}
	
	@Override
	public List<CfOrderItem> selectOrderItemByAdminUserId(Integer adminUserId, Integer deliveryStatus) {
		CfOrderItemExample example=new CfOrderItemExample();
		Criteria criteria = example.createCriteria();
		criteria.andAdminUserIdEqualTo(adminUserId);
		if (deliveryStatus!=0) {
			criteria.andDeliveryStatusEqualTo(deliveryStatus.byteValue());
		}
		List<CfOrderItem> list = itemMapper.selectByExample(example);
		return list;
	}

	@Override
	public int updateOrderItem(CfOrderItem orderItem) {
		int i = itemMapper.updateByPrimaryKeySelective(orderItem);
		return i;
	}

}
